Skip to content

tests: exercise the per-minute event/query rate limits#153

Merged
kwsantiago merged 1 commit into
mainfrom
rate-limit-integration-test
Jul 12, 2026
Merged

tests: exercise the per-minute event/query rate limits#153
kwsantiago merged 1 commit into
mainfrom
rate-limit-integration-test

Conversation

@kwsantiago

Copy link
Copy Markdown
Contributor

What

Add tests/integration_ws_rate_limit.sh (+ a CI step) that drives real traffic to prove the per-IP events_per_minute / queries_per_minute throttles actually fire.

Why

The connection limit is covered (integration_ws_idle_reclaim.sh, 429), but the event/query rate limits were untested. handler.zig sends ["OK",id,false,"rate-limited: too many events"] (:271) and ["CLOSED",sub,"rate-limited: too many queries"] (:456) and bumps metrics.rateLimited() on the throttle path — none of it exercised.

How

The rejections are sent over a live connection (a unit test can't see them), so the test drives real traffic and reads the throttle back from the Prometheus counters that increment only on the rate-limit path:

  • Burst BURST=8 valid, uniquely-tagged kind-1 events at LIMIT=3 (so a rejection can only be the rate limit, never a bad sig / duplicate / disallowed kind). Assert the first few are accepted, the excess rejected, and wisp_rate_limited_total rose by the throttled count.
  • Burst REQs and assert wisp_query_rate_limited_total rose.

The token bucket starts full and refills at LIMIT/60/sec (~negligible over the ~1-2s burst); the assertions allow one refill token of slack (>= BURST-LIMIT-1) so a slow runner can't flake.

CI starts a dedicated relay with WISP_EVENTS_PER_MINUTE=3 WISP_QUERIES_PER_MINUTE=3 on port 7787 (mirrors the idle-reclaim step); requires the noz client the suite already builds.

Verification

Ran locally against zig build wisp + noz v0.2.1: 4/4 assertions pass, stable across 3 runs. Negative control (relay started with limits 100000, throttle effectively off): the test fails (0 throttled) — so it genuinely guards the behavior.

Addresses privkeyio/keep-node#11 (the wisp-side rate-limit coverage tracked as keep-node-h3o).

Signed-off-by: Kyle 🐆 <kyle@privkey.io>
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@kwsantiago, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 7 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1d4f9726-0feb-4f87-b441-63a29c9f6e34

📥 Commits

Reviewing files that changed from the base of the PR and between e91931d and e305dce.

📒 Files selected for processing (2)
  • .github/workflows/ci.yml
  • tests/integration_ws_rate_limit.sh
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch rate-limit-integration-test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kwsantiago
kwsantiago merged commit 5863ff4 into main Jul 12, 2026
4 of 5 checks passed
@kwsantiago
kwsantiago deleted the rate-limit-integration-test branch July 12, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant